package cn.ncupyh.soft;

import cn.ncupyh.soft.book.BookList;
import cn.ncupyh.soft.user.AdminUser;
import cn.ncupyh.soft.user.NormalUser;
import cn.ncupyh.soft.user.User;

import java.util.Scanner;

/**
 * @version 1.8
 * @Author Djx_hmbb
 * @Date 2023/7/22 10:06
 * @注释:
 */
public class  TestBook {
    //登录
    public static User login(){
        System.out.println("请输入你的姓名:");
        Scanner s = new Scanner(System.in);
        String name = s.next();
        while (true){
            System.out.println("请输入你的身份:1->管理员  0->普通用户");
            String identify = s.next();
            if(identify.equals("1")){
                return new AdminUser(name);
            }else if(identify.equals("0")){
                return new NormalUser(name);
            }else System.out.println("输入错误,请重新输入!");
        }
    }
    public static void main(String[] args) {
        User user = login();//确认身份:管理员/普通用户
        BookList bookList = new BookList();
        while (true){
            int choice = user.menu();//得到命令序号
            user.doWork(choice,bookList);//使用命令
        }

    }
}